package cn.fzkj.springboot.domain;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface EmployeeRepository extends JpaRepository<Employee, Integer> {

    @Transactional
    @Modifying
    @Query("update Employee em set em.name = :#{#employee.name}, em.email=:#{#employee.email}, em.gender=:#{#employee.gender}, em.dId=:#{#employee.dId} where em.id = :#{#employee.id}")
    public int updateEmp(Employee employee);


    @Query("select emp from Employee emp where emp.name = ?1")
    Employee findEmpByName(String name);

    @Query("select emp from Employee emp where emp.id = ?1")
    Employee getById(int id);
}
